<template>
	<div>
		<!-- <el-select
		    size="mini"
		    v-model="mid"
		    filterable
		    remote
		    reserve-keyword
		    :placeholder="holder"
		    :remote-method="remoteMethod"
		    :loading="loading">
		    <el-option
		      v-for="item in options"
		      :key="item.id"
		      :label="item.name"
		      :value="item.id">
		    </el-option>
		  </el-select> -->
		  <el-input size="mini" v-model="keywords" 
		    @keyup.enter.native="callEnter"
			@input="remoteMethod"
			:placeholder="holder"></el-input>
	</div>
</template>

<script>
	export default {
		data(){
			return {
				 loading:false,
				 options:[],
				 mid:'',
				 keywords:""
			}
		},
		props:{
			holder:{
				type:String,
				default:'请输入用户姓名/手机号'
			}
		},
		watch:{
			mid(newVal){
				this.$emit('getUserId',this.mid)
			},
			// phone(newVal){
			// 	this.mid = newVal
			// },
		},
		mounted() {
			// this.phone = this.pphone
		},
		methods:{
			callEnter(){
				console.log(11)
				this.$emit('callEnter')
			},
			remoteMethod() {
				let keywords = this.keywords
				if (keywords !== '') {
					 this.loading = true;
					  this.$post('/user/getUserAll',{keywords},res=>{
						  let result = res.data.data
						   this.loading = false
						  if(result.length){
							  this.mid = result.map((item)=>{
								  return item.mid
							  })
						  }
					  })
				} else {
				  this.options = [];
				}
		  }
		}
	}
</script>

